import customer from '@/api/crm/customerAPI'
import { mapGetters } from 'vuex'
import Mixins from '@/views/mixins'
export default {
  mixins: [Mixins],
  data () {
    return {
      customerChannels: [],
      tagOptions: [],
      tagGroupOptions: []
    }
  },
  computed: {
    ...mapGetters(['customerLevels'])
  },
  created () {
    this.getCustomerChannels()
    this.initPageList()
  },
  methods: {
    getRequestType () {
      if (this.id === 'customer') {
        return customer.getCustomerInfoListAPI
      }
    },
    getCustomerChannels () {
      customer.getCustomerSourceChannelListAPI().then(res => {
        this.customerChannels = res.data || []
      })
    },
    formatterLevelColor (value) {
      const level = this.customerLevels.filter(item => {
        if (item.value === value) {
          return item
        }
      })
      return level && level.length > 0 ? level[0].color : ''
    },
    formatterLevel (value) {
      const level = this.customerLevels.filter(item => {
        if (item.value === value) {
          return item
        }
      })
      return level && level.length > 0 ? value + '(' + level[0].label + ')' : value
    },
    formatterChannel (row, colum) {
      const channel = this.customerChannels.filter(item => {
        if (item.bizValue === row.channel) {
          return item
        }
      })
      return channel && channel.length > 0 ? channel[0].bizName : row.channel
    }

  }
}
